/*
 * Copyright (C) 2011 Project R'yleh Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.Arkham;

import android.os.Parcel;
import android.os.Parcelable;


public class Item implements Parcelable {
   private String name;
   private Stats modifiers = new Stats();
   private String equippedBy;
   private int equippedAt;
   private int purchasePrice;
   private int sellPrice;
   private boolean[] equipableArea = new boolean[Constants.EQUIPPABLE_AREAS];
   private boolean[] itemType = new boolean[Constants.TOTAL_ITEM_TYPES];

   public Item() {
	   name = "";
	   equippedBy = null;
	   purchasePrice = 0;
	   sellPrice = 0;
	   for(int i=0; i<Constants.EQUIPPABLE_AREAS; i++)
		   equipableArea[i] = false;
	   for(int i=0; i<Constants.TOTAL_ITEM_TYPES; i++)
		   itemType[i] = false;
	   equippedAt = -1;
   }
   
   //////////////////////////////////////////////////////////
   /* everything below here is for implementing Parcelable */
   //////////////////////////////////////////////////////////

   public int describeContents() {
       return 0;
   }

   // write object's data to the passed-in Parcel
   // note that modifiers are not passed in because they are not a supported type.
   public void writeToParcel(Parcel out, int flags) {
       out.writeString(name);
       out.writeString(equippedBy);
       out.writeInt(equippedAt);
       out.writeInt(purchasePrice);
       out.writeInt(sellPrice);
       out.writeBooleanArray(equipableArea);
       out.writeBooleanArray(itemType);
//       out.writeIntArray(modifiers.getStatsArray());
   }

   // this is used to regenerate the object. 
   // All Parcelables must have a CREATOR that implements these two methods
   public static final Parcelable.Creator<Item> CREATOR = new Parcelable.Creator<Item>() {
       public Item createFromParcel(Parcel in) {
           return new Item(in);
       }

       public Item[] newArray(int size) {
           return new Item[size];
       }
   };

   // example constructor that takes a Parcel and gives you an object populated with it's values
   private Item(Parcel in) {
       name = in.readString();
       equippedBy = in.readString();
       equippedAt = in.readInt();
       purchasePrice = in.readInt();
       sellPrice = in.readInt();
       equipableArea = in.createBooleanArray();
       itemType = in.createBooleanArray();
//     modifiers
   }

   //////////////////////////////////////////////////////////
   /* everything above here is for implementing Parcelable */
   //////////////////////////////////////////////////////////
   
   public void setName(String newName){
	   name = newName;
   }
   
   public String getName(){
	   return name;
   }
   
   public void setEquippedBy(String newName){
	   equippedBy = newName;
   }
   
   public String getEquippedBy(){
	   return equippedBy;
   }
   
   public void setPurchasePrice(int price){
	   purchasePrice = price;
   }
   
   public int getPurchasePrice(){
	   return purchasePrice;
   }
   
   public void setSellPrice(int price){
	   sellPrice = price;
   }
   
   public int getSellPrice(){
	   return sellPrice;
   }
   
   public void setEquipableArea(int area, boolean equipable){
	   equipableArea[area] = equipable;
   }
   
   public boolean isEquipable(int area){
	   return equipableArea[area];
   }
   
   public void setItemType(int type, boolean setType){
	   itemType[type] = setType;
   }
   
   public boolean isItemType(int type){
	   return itemType[type];
   }
   
   public int getStrengthModifier(){
	   return modifiers.getStrength();
   }
   
   public void setStrengthModifier(int newValue){
	   modifiers.setStrength(newValue);
   }
   
   public int getAgilityModifier(){
	   return modifiers.getAgility();
   }
   
   public void setAgilityModifier(int newValue){
	   modifiers.setAgility(newValue);
   }
   
   public int getVitalityModifier(){
	   return modifiers.getVitality();
   }
   
   public void setVitalityModifier(int newValue){
	   modifiers.setVitality(newValue);
   }
   
   public int getMagicModifier(){
	   return modifiers.getMagic();
   }
   
   public void setMagicModifier(int newValue){
	   modifiers.setMagic(newValue);
   }
   
   public int getAttackPowerModifier(){
	   return modifiers.getAttackPower();
   }
   
   public void setAttackPowerModifier(int newValue){
	   modifiers.setAttackPower(newValue);
   }
   
   public int getHitPercentageModifier(){
	   return modifiers.getHitPercentage();
   }
   
   public void setHitPercentageModifier(int newValue){
	   modifiers.setHitPercentage(newValue);
   }
   
   public int getDefenseModifier(){
	   return modifiers.getDefense();
   }
   
   public void setDefenseModifier(int newValue){
	   modifiers.setDefense(newValue);
   }
   
   public int getEvadeModifier(){
	   return modifiers.getEvade();
   }
   
   public void setEvadeModifier(int newValue){
	   modifiers.setEvade(newValue);
   }
   
   public int getMagicDefenseModifier(){
	   return modifiers.getMagicDefense();
   }
   
   public void setMagicDefenseModifier(int newValue){
	   modifiers.setMagicDefense(newValue);
   }
   
   public int getMagicEvadeModifier(){
	   return modifiers.getMagicEvade();
   }
   
   public void setMagicEvadeModifier(int newValue){
	   modifiers.setMagicEvade(newValue);
   }
   
   public int getMaxHealthModifier(){
	   return modifiers.getMaxHealth();
   }
   
   public void setMaxHealthModifier(int newValue){
	   modifiers.setMaxHealth(newValue);
   }
   
   public int getMaxMagicModifier(){
	   return modifiers.getMaxMagic();
   }
   
   public void setMaxMagicModifier(int newValue){
	   modifiers.setMaxMagic(newValue);
   }
   
   public Stats getModifiers(){
	   return modifiers;
   }
   
   public void setModifiers(Stats newMods){
	   modifiers = newMods;
   }
   public int[] getModifiersArray(){
	   return modifiers.getStatsArray();
   }
   
   public void setModifiersArray(int[] newModifiers){
	   modifiers.setStatsArray(newModifiers);
   }
   
   public void setEquippedAt(int L){
	   equippedAt = L;
   }
   
   public int getEquippedAt(){
	   return equippedAt;
   }
}